package com.broada.apm.base;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.broada.apm.logic.AlertLogic;
import com.broada.apm.logic.AnalyzerLogic;
import com.broada.apm.logic.ApplicationLogic;
import com.broada.apm.logic.AuthenticationLogic;
import com.broada.apm.logic.ConfigLogic;
import com.broada.apm.logic.IndicatorLogic;
import com.broada.apm.logic.L7ModuleLogic;
import com.broada.apm.logic.PerformanceLogic;
import com.broada.apm.logic.ProtocalLogic;
import com.broada.apm.logic.RelationLogic;
import com.broada.apm.logic.ResourceLogic;
import com.broada.apm.logic.ServerLogic;
import com.broada.apm.logic.ServicePerformanceLogic;
import com.broada.apm.logic.SystemLogic;
import com.broada.apm.logic.TradePerformanceLogic;
import com.broada.apm.logic.TransactionLogic;

public class BaseService {

	private Logger log = LoggerFactory.getLogger(BaseService.class);
	@Autowired
	public ServerLogic serverLogic;
	@Autowired
	public RelationLogic relLogic;
	@Autowired
	public ApplicationLogic appLogic;
	@Autowired
	public PerformanceLogic perfLogic;
	@Autowired
	public ConfigLogic confLogic;
	@Autowired
	public ResourceLogic resLogic;
	@Autowired
	public AlertLogic alertLogic;
	@Autowired
	public ProtocalLogic protoLogic;
	@Autowired
	public AuthenticationLogic authenticationLogic;
	@Autowired
	public SystemLogic systemLogic;
	@Autowired
	public IndicatorLogic indicatorLogic;
	@Autowired
	public TradePerformanceLogic tradePerformanceLogic;
	@Autowired
	public TransactionLogic transactionLogic;
	@Autowired
	public ServicePerformanceLogic servicePerformanceLogic;
	@Autowired
	public L7ModuleLogic l7ModuleLogic;
	@Autowired
	public AnalyzerLogic analyzerLogic;
	/**
	 * url参数解码
	 * 
	 * @param ids
	 * @return
	 */
	public String[] decoderArry(String ids) {
		String[] idArry = new String[0];
		if (ids != null) {
			try {
				ids = URLDecoder.decode(ids, "utf-8");
				idArry = ids.split(",");
			} catch (UnsupportedEncodingException e) {
				log.error("url参数解码失败:%s", e.getMessage());
			}
		}
		return idArry;
	}

	public String decoderString(String id) {
		if (id != null) {
			try {
				id = URLDecoder.decode(id, "utf-8");
			} catch (UnsupportedEncodingException e) {
				log.error("url参数解码失败:%s", e.getMessage());
			}
		}
		return id;
	}
}
